package com.dj.dormitory.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dj.dormitory.entity.Absence;
import com.dj.dormitory.entity.req.AbsenceReq;
import com.dj.dormitory.entity.vo.AbsenceVo;
import com.dj.dormitory.mapper.AbsenceMapper;
import com.dj.dormitory.service.AbsenceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author DJ同学
 * @since 2021-01-24
 */
@Service
public class AbsenceServiceImpl extends ServiceImpl<AbsenceMapper, Absence> implements AbsenceService {


    @Override
    public Page<Absence> getList(Map map) {
        Integer curr = (Integer) map.get("page");
        Integer size = (Integer) map.get("limit");
        Page<Absence> page = new Page<>(curr,size);
        QueryWrapper<Absence> wrapper = new QueryWrapper<>();
        if(map.containsKey("key")&& !StringUtils.isEmpty((String)map.get("key"))){
            wrapper.like("student_name",map.get("key"));
        }
        if(map.containsKey("sno")){
            wrapper.eq("sno",map.get("sno"));
        }
        this.baseMapper.selectPage(page,wrapper);
        return page;
    }
}
